package com.example.demo.common;

import com.example.common.entity.UserInfo;
import com.example.common.tools.UserSessionUtils;
import com.example.demo.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.servlet.http.HttpServletRequest;


@Configuration
public class UpdateInfoUtils {

    @Autowired
    private CommentService commentService;

    /**
     * 更新 session 信息和评论中的用户信息
     * @param request
     * @param userInfo
     */
    public void updateSessionAndComment(HttpServletRequest request, UserInfo userInfo) {
        //1.更新 session 信息
        UserSessionUtils.updateSession(request, userInfo);
        //2.更新评论中的用户信息
        commentService.updateCommentByUid(userInfo);
    }



}
